<?php

include('header.php');
$smarty->assign('media', siteinfo('media'));
include('bottom_banners.php');
include('chat.php');
include('sidebar_banners.php');

$paginatorMainPosts = new Paginator;
$paginatorMainPosts->mid_range = 5;


if (isset($_GET['kategorija']) && !empty($_GET['kategorija'])) {
    $category = mres($_GET['kategorija']);
    $paginatorMainPosts->items_total = totalMainPostsByCategory($category);
    $paginatorMainPosts->paginate();
    $mainPosts = getMainPostByCategory($paginatorMainPosts->limit, $category);
} else {
    $paginatorMainPosts->items_total = totalMainPosts();
    $paginatorMainPosts->paginate();
    $mainPosts = getMainPost($paginatorMainPosts->limit);
}
$smarty->assign('mainPosts', $mainPosts);
$smarty->assign('paginatorMainPosts', $paginatorMainPosts->display_pages());
$smarty->assign('kategorije', getCategories());

$smarty->display('magazin.tpl');

include('footer.php');
?>
